package com.jeasonzhao.report.vml.base;


public class LineText extends Line
{
    public LineText()
    {
        super();
    }

    public LineText(Vector2D from,Vector2D to)
    {
        super(from,to);
    }

    public LineText(int x1,int y1,int x2,int y2)
    {
        super(x1,y1,x2,y2);
    }

    public static LineText HorizonLineText(int x,int y,int nLength)
    {
        return new LineText(new Vector2D(x,y),new Vector2D(x + nLength,y));
    }

    public static LineText HorizonLineText(Vector2D pt,int nLength)
    {
        return new LineText(new Vector2D(pt.getX(),pt.getY()),
                            new Vector2D(pt.getX() + nLength,pt.getY()));
    }

    public static LineText VerticalLineText(int x,int y,int nLength)
    {
        return new LineText(new Vector2D(x,y),new Vector2D(x,y + nLength));
    }

    public static LineText VerticalLineText(Vector2D pt,int nLength)
    {
        return new LineText(new Vector2D(pt.getX(),pt.getY()),
                            new Vector2D(pt.getX(),pt.getY() + nLength));
    }

    public String getTagName()
    {
        return "line";
    }

    public void setText(String strText)
    {
        if(null == strText)
        {
            return;
        }
        Path p = (Path)this.getSubVmlElement(Path.class);
        if(p == null)
        {
            p = new Path();
            p.setIsTextPath(true);
            this.addSubVmlElement(p);
        }
        TextPath tp = (TextPath)this.getSubVmlElement(TextPath.class);
        if(null == tp)
        {
            tp = new TextPath();
            this.addSubVmlElement(tp);
        }
        tp.setFitpath(true);
        tp.setOn(true);
        tp.setText(strText);
    }

    public static void main(String str[])
        throws Exception
    {
        LineText text = new LineText();
        text.setFrom(100,100);
        text.setTo(0,0);
        text.setText("Test");
        System.out.println(text.getScript());
    }
}
